﻿using System;
using System.IO;
using LBNet;

public class Connection_AS : NetWork
{
    private static Connection_AS mInstance = null;
    public static Connection_AS Instance
    {
        get
        {
            if (mInstance == null)
            {
                mInstance = new Connection_AS();
            }
            return mInstance;
        }
    }

    protected override void InitialProtocol()
    {
        //RegisterMsg((ushort)OpCode.login, "c_as.AllGameServerInfo", new ProtocolHandler(UI_Login.Instance.ServerEveLogin));
        //RegisterMsg((ushort)OpCode.chose_game_server, "c_as.ChoseCameServerACK", new ProtocolHandler(UI_Login.Instance.GetACK));

    }

    public void SendRPC(AsOpCode op)
    {
        SendRPC((ushort)op);

        //if (op != OpCode.heart_beat)
        //    Global.Log("send:" + op.ToString());
    }

    public void SendRPC<T>(AsOpCode op, T rpc)
    {
        SendRPC<T>((ushort)op, rpc);
    }

    protected override void OnConnected(object src, EventArgs arg)
    {
        Debugger.Log("连接账号服务器成功");
        base.OnConnected(src, arg);

    }

    protected override void OnConnectFailed(object src, EventArgs arg)
    {
        Debugger.Log("连接账号服务器失败");
        base.OnConnectFailed(src, arg);
    }

    protected override void OnDisconnected(object src, EventArgs arg)
    {
        Debugger.Log("断开账号服务器");
        base.OnDisconnected(src, arg);

    }
}

public enum AsOpCode 
{
    Error = 0,
    Login = 1,
    Chose_game_server = 2
}